package day14_21.day19;

import java.util.Scanner;

public class Main02 {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        String str1 = scn.next();
        String str2 = scn.next();
        StringBuffer stringBuffer = new StringBuffer();
        String[] str1A = str1.split("");
        String[] str2A = str2.split("");
        int max = 0;
        for (int i = 0 ; i < str1A.length ; i ++){
            for (int j = 0; j < str2A.length; j++) {
                int n = i;
                while (str1A[i].equals(str2A[j]) && i < str1A.length - 1  && j < str2A.length - 1){
                    i ++;
                    j ++;
                }
                if (i - n > max){
                    String s = str1.substring(n , i );
                    stringBuffer.delete(0 , stringBuffer.length());
                    stringBuffer.append(s);
                    max = Math.max(i - n , max);
                }
                i = n;

            }
        }
        System.out.println(stringBuffer.toString());
    }
}
